//  IdentityReigster.m
//  XJMTechnician
//  Created by Mr.hu on 2017/10/18.
//  Copyright © 2017年 Mr.hu. All rights reserved.

#import "IdentityReigster.h"
#import "PaySecretFirst.h"
#import "RegisterIdentityCard.h"
#import "AddSomepersonVC.h"
#import "UploadingHeadimgeVC.h"

@interface IdentityReigster ()<UITextFieldDelegate>
@property (weak, nonatomic) IBOutlet UITextField *IdentityNameLab;
@property (weak, nonatomic) IBOutlet UITextField *Identity_Gender;
@property (weak, nonatomic) IBOutlet UITextField *Identity_Birth;
@property (weak, nonatomic) IBOutlet UITextField *IdentityPersonIntro;
@property (weak, nonatomic) IBOutlet UIButton *IdentityNextSubmit;

@property (nonatomic,copy) NSString * IdentityInformation; //身份证信息
@property (nonatomic,copy) NSString * Identity_fontImage;
@property (nonatomic,copy) NSString * Identity_coverImage;
@property (nonatomic,copy) NSString * Choice_Skill;

@property (weak, nonatomic) IBOutlet UIButton *Upload_HeadImage;

@end

@implementation IdentityReigster

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:animated];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"身份信息";
    self.IdentityNextSubmit.layer.cornerRadius = 22;
    self.IdentityNextSubmit.layer.masksToBounds = YES;
    
    self.Identity_Birth.delegate = self;
    self.Identity_Gender.delegate = self;
    self.IdentityNameLab.delegate = self;
    self.IdentityPersonIntro.delegate = self;
    
    UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(jkr_tapGestureAction:)];
    tapGestureRecognizer.cancelsTouchesInView = NO;
    [self.view addGestureRecognizer:tapGestureRecognizer];
}

- (void)jkr_tapGestureAction:(UITapGestureRecognizer *)tapGusture{
    [self.view endEditing:YES];
}

-(BOOL)textFieldShouldReturn:(UITextField *)textField{
    
    [self.Identity_Birth resignFirstResponder];
    [self.Identity_Gender resignFirstResponder];
    [self.IdentityNameLab resignFirstResponder];
    [self.IdentityPersonIntro resignFirstResponder];
    return NO;
}

- (IBAction)IdentityNextMeth:(id)sender {
    
    if (self.IdentityInformation != nil && self.Identity_fontImage != nil && self.Identity_coverImage != nil) {
        NSString * sexstr = [[NSString alloc]init];
        if ([self.Identity_Gender.text isEqualToString:@"男"]) {
            sexstr = @"1";
        }else{
            sexstr = @"2";
        }
    
        if (self.IdentityNameLab.text == nil || self.IdentityInformation==nil || self.Identity_Birth.text==nil ||self.Choice_Skill==nil || self.Identity_fontImage==nil || self.Identity_coverImage ==nil ) {
            [XJToolClass tipAnimationWith:@"请补全身份信息!"];
        }else{
        
    [XJHttpClass TeachRegistertid:[TechSimple registerpass].User_TechID Second_account:[TechSimple registerpass].User_TechPhone Pwd:nil city:@"武汉" truename:self.IdentityNameLab.text card:self.IdentityInformation sex:sexstr birthday:self.Identity_Birth.text desc:self.Choice_Skill idcard_zheng:self.Identity_fontImage idcard_fan: self.Identity_coverImage andFinishblock:^(id response, NSString *errStr) {
        
        if (errStr) {
            [XJToolClass tipAnimationWith:errStr];
        }else{
            
            PaySecretFirst * paysecret = [[PaySecretFirst alloc]init];
            [self.navigationController pushViewController:paysecret animated:false];
        }
        
    }];
        }
    }else{
        [XJToolClass tipAnimationWith:@"请补全信息!"];
    }
}

- (IBAction)IdentityAuthenActionMeth:(id)sender {
    
    RegisterIdentityCard * paysecret = [[RegisterIdentityCard alloc]initWithBlock:^(NSString *identinformation, NSString *identicover, NSString *identifont) {
        self.IdentityInformation = identinformation;
        self.Identity_fontImage =  identifont;
        self.Identity_coverImage = identicover;
    }];
    
    [self.navigationController pushViewController:paysecret animated:YES];
}

- (IBAction)PersonTeachSkill:(id)sender {
   
    AddSomepersonVC * paysecret = [[AddSomepersonVC alloc]initWithBlock:^(NSString *somepeople, NSString *Somepeople_name) {
        self.Choice_Skill = somepeople;
    }];
    
    [self.navigationController pushViewController:paysecret animated:YES];
}

- (IBAction)UploadingHeadingMeth:(id)sender {
    
    //头像上传成功
    __weak __typeof__(self)weakSelf=self;
    
    UploadingHeadimgeVC * minecollect = [[UploadingHeadimgeVC alloc]initWithBlock:^(NSString *name) {
        NSLog(@"blocked：%@",name);
        [weakSelf.Upload_HeadImage setTitle:name forState:(UIControlStateNormal)];
    }];
    minecollect.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:minecollect animated:YES];
    
}


@end
